package exo1;

import exo1.Point;

public class Image extends Forme implements Checked {

	private Point origine;
	private GenericList<Forme> formes;
	private int nbFormes;
	/**
	 *  la taille maxiamal de l'image
	 */
	private final int MAX_FORM=20;
	
	public Image(Point point) {
		this();
		this.origine=point;
	}
	public Image() {
	  formes=new GenericList<Forme>();
	}
	
	public void ajouter(Forme forme){
			invariant();
			formes.add(forme);
			invariant();
	}
	@Override
	public void deplacer(Point point) {
		origine=origine.additioner(point);
	}

	@Override
	public void dessiner(PileTransformations p) {
		System.out.println("Image [origine=" + origine + ", nbFormes=" + nbFormes);
		p.empiler(origine);
		for(int i=0;i<nbFormes;i++){
//			formes[i].dessiner(p);
		}
		//comment je parcours le ma collection avec un iterateur 
		p.depiler();

	}

	public Point getOrigine() {
		return origine;
	}

	public void setOrigine(Point origine) {
		this.origine = origine;
	}

	public int getNbFormes() {
		return nbFormes;
	}
	@Override
	public String toString() {
		return "Image [origine=" + origine + ", nbFormes=" + nbFormes
				+ ", MAX_FORM=" + MAX_FORM + "]";
	}
	@Override
	public void invariant() {
		assert nbFormes <MAX_FORM:"nbFormes>MAX_FORM";
		
	}
	

}
